/**
 * #### 判断是否是稀疏数组
 * @description 判断是否是稀疏数组;/spɑːrs/
 * @see https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
 * @see https://www.bilibili.com/video/BV1rdKHeiEJ5?spm_id_from=333.788.videopod.sections&vd_source=9efadbd9bd76b9c14f9589f260a0c1ac
 * @category Array
 * @param arr 任意类型
 * @returns boolean
 * @example
 * ```ts
 * isSparseArray([1,2,3,4,5]) // false
 * isSparseArray([1,2,3,,4,5]) // true
 * ```
 */
export function isSparseArray(arr: any) {
  if (!Array.isArray(arr)) return false;
  for (let i = 0; i < arr.length; i++) {
    if (!(i in arr)) return true;
  }
  return false;
}
